package org.come.Jpanel;

import com.tool.tcpimg.ChatBox;
import com.tool.tcpimg.UIUtils;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.GameJpanel;
import org.come.Jpanel.MsgJframe2;
import org.come.entity.RoleSummoning;
import org.come.until.FormsManagement;

import javax.swing.*;
import java.awt.*;

/**
 *
 * @author Administrator
 *
 */
public class MsgJapnel2 extends JPanel {

    // 描述框
    private ChatBox box;

    // 展示的位置大小
    private int boxx;
    private int boxy;
    private int boxw;
    private int boxh;
    private String vc;
    public boolean open= false;
    public MsgJapnel2() {
        // TODO Auto-generated constructor stub
        box = new ChatBox();
        box.setAlpha(0.6f);
        this.setLayout(null);
        this.setBackground(new Color(0, 0, 0, 0));
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics g3 = g.create(0, 0, boxw, boxh);
        box.paintSSS(g3);
        g3.dispose();
        Graphics2D g2d = (Graphics2D) g;
        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        if (open){
            g2d.setFont(UIUtils.TEXT_FONT_17);
            g2d.setColor(new Color(248,252,112));
            g2d.drawString(vc, 7, 23);
            g2d.drawString(vc, 7, 23);
            g2d.drawString(vc, 8, 23);
        }else {
            g2d.setFont(UIUtils.TEXT_FONT_17);
            g2d.setColor(new Color(130,174,255));
            g2d.drawString(vc, 7, 20);
            g2d.drawString(vc, 7, 20);
            g2d.drawString(vc, 7, 20);
        }

    }


    /** 灵犀展示 */
    public void LX(String name, String msg) {
        box.removemsg();
        vc=name;
        open = false;
        box.removeAddText(" " , 310, UIUtils.TEXT_FONT_17);
        box.addText(msg, box.getWidth(), UIUtils.TEXT_FONT1);
        boxw = box.getWidth()+10;// 宽
        boxh = box.getHeight();
        Point goodx = ZhuFrame.getZhuJpanel().framepoint(GameJpanel.getGameJpanel().getMousePosition(),
                new Dimension(boxw, boxh));
        boxx = (int) goodx.getX();
        boxy = (int) goodx.getY();
        displaymsg();
    }

    /** 天演策展示 */
    public void TYC(String name, String msg) {
        box.removemsg();
        vc=name;
        open =true;
        box.addText("#r ", 300, UIUtils.TEXT_FONT_17);
        box.addText(msg, 295, UIUtils.TEXT_FONT1);
        boxw = 315;// 宽
        boxh = box.getHeight();
        Point goodx = ZhuFrame.getZhuJpanel().framepoint(GameJpanel.getGameJpanel().getMousePosition(),
                new Dimension(boxw, boxh));
        boxx = (int) goodx.getX()-10;
        boxy = (int) goodx.getY()+20;
        displaymsg();
    }
    /** 宠物成长展示 */
    public void petMsgsCZ(String name,  RoleSummoning pet) {
        String msg = " 基础成长："+(Double.parseDouble(pet.getGrowlevel())-pet.getDragon()*0.01-pet.getSpdragon()*0.01);
        msg += "#r 龙骨："+(pet.getDragon()*0.01);
        msg += "#r 超级龙骨："+(pet.getSpdragon()*0.01);
        box.removemsg();
        vc=name;
        open =true;
        box.addText("#r ", 125, UIUtils.TEXT_FONT_17);
        box.addText(msg, 125, UIUtils.TEXT_FONT1);
        boxw = 125;// 宽
        boxh = box.getHeight();
        Point goodx = ZhuFrame.getZhuJpanel().framepoint(GameJpanel.getGameJpanel().getMousePosition(),
                new Dimension(boxw, boxh));
        boxx = (int) goodx.getX()-10;
        boxy = (int) goodx.getY()+20;
        displaymsg();
    }
    /** 宠物四围展示 */
    public void petMsgsSW(String msg,  RoleSummoning pet) {
        box.removemsg();
        vc=msg.contains("气血")?"气血初值":msg.contains("法力")?"法力初值":msg.contains("攻击")?"攻击初值":msg.contains("速度")?"速度初值":"";
        msg = msg.replaceAll("气血|法力|攻击|速度", "基础：");
        open =true;
        box.addText("#r ", 125, UIUtils.TEXT_FONT_17);
        box.addText(msg, 125, UIUtils.TEXT_FONT1);
        boxw = 125;// 宽
        boxh = box.getHeight();
        Point goodx = ZhuFrame.getZhuJpanel().framepoint(GameJpanel.getGameJpanel().getMousePosition(),
                new Dimension(boxw, boxh));
        boxx = (int) goodx.getX()-10;
        boxy = (int) goodx.getY()+20;
        displaymsg();
    }
    /** 快捷栏 */
    public void KJL(String name, String msg) {
        box.removemsg();
        vc=name;
        open =true;
        box.addText("#r ", 300, UIUtils.TEXT_FONT_17);
        box.addText("#G"+msg, 295, UIUtils.TEXT_FONT1);
        boxw = 310;// 宽
        boxh = box.getHeight();
        Point goodx = ZhuFrame.getZhuJpanel().framepoint(GameJpanel.getGameJpanel().getMousePosition(),
                new Dimension(boxw, boxh));
        boxx = (int) goodx.getX()+100;
        boxy = (int) goodx.getY()+180;
        displaymsg();
    }


    // 显示提示框
    public void displaymsg() {
        MsgJframe2.getJframe2().setBounds(boxx, boxy, boxw, boxh);
        FormsManagement.showForm(628);
    }

    public ChatBox getBox() {
        return box;
    }

    public void setBox(ChatBox box) {
        this.box = box;
    }
}
